package com.yz.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yz.entity.Computer;
import com.yz.entity.Membership;
import com.yz.entity.dto.ComputerDto;
import com.yz.entity.dto.MembershipDto;
import com.yz.service.ComputerService;
import com.yz.util.Result;

@RestController
public class ComputerController {
	@Autowired
	private ComputerService computerService;
	
	@RequestMapping("/getCompList")
	public Object getCompList(ComputerDto computerDto,Computer computer) {
		List<Computer> list = computerService.getComp(computerDto);
		computerDto.setPage(null);
		computerDto.setLimit(null);
		List<Computer> list2 = computerService.getComp(computerDto);
		return new Result(0,"",list2.size(),list);
	}
	
	@RequestMapping("/addComp")
	public Object addComp(Computer computer) {
		if(computerService.addComp(computer)) {
			return new Result(0,"添加成功");
		}else {
			return new Result(1,"添加失败");
		}
	}
	
	@RequestMapping("/updateComp")
	public Object updateComp(Computer computer) {
		if(computerService.updateComp(computer)) {
			return new Result(0,"修改成功");
		}else {
			return new Result(1,"修改失败");
		}
	}
	
	@RequestMapping("/delComp")
	public Object delComp(int cid) {
		if(computerService.delComp(cid)) {
			return new Result(0,"删除成功");
		}else {
			return new Result(1,"删除失败");
		}
	}
	
	@RequestMapping("/getAllRead")
	public Object getAllRead() {
		return new Result(0,"",computerService.getAllRead());
	}
}
